package com.neuedu.corejava.ch10test;

import java.util.Scanner;

public class HomeWork7 {

	public static void main(String[] args) {

		
		if(args==null || args.length==0) {//判断是否从控制台输入参数：
			//
			System.out.println("没有从控制台输入参数");
			Scanner scanner=new Scanner(System.in);
			String input=scanner.nextLine();
			args=input.split(",");
		}
		printStringArray(args);
		bubbleSortDesc(args);
		printStringArray(args);
	}
	
	private static void  printStringArray(String[] array) {
		
		for (String s  : array) {
			System.out.print(s+"\t");
		}
		System.out.println();
	}
	
	public static void bubbleSortDesc(String[] data) {
		if (data == null) {
			return;
		}
		for (int i = 0; i < data.length; i++) {
			for (int k = 0; k < data.length - 1 - i; k++) {
				String tmp = data[k];
				if (data[k].compareToIgnoreCase(data[k + 1])>0) {// 升序和降序控制，小于号是降序排序
					data[k] = data[k + 1];
					data[k+1]=tmp;
				}
			}
		}
	}
}
